package net.atomarrow.db.parser;

import java.io.Serializable;
/**
 * 条件
 * @author Michael
 *
 */
public class Condition {
	private Serializable fieldName;
	private Serializable value1;
	private Serializable value2;
	private Serializable compareState;
	private String link;

	public Condition() {

	}

	public Condition(Serializable fieldName, Serializable value,
			String compareState) {
		this.value1 = value;
		this.compareState = compareState;
		setFieldName(fieldName);
	}

	public Condition(Serializable fieldName, Serializable value1,
			Serializable value2, String compareState) {
		this.value1 = value1;
		this.value2 = value2;
		this.compareState = compareState;
		setFieldName(fieldName);
	}

	public Serializable getFieldName() {
		return fieldName;
	}

	public void setFieldName(Serializable fieldName) {
		if(compareState.equals(Conditions.EXP)&&fieldName==null){
			return;
		}
		this.fieldName = ValueProcessor.safeProcess(fieldName);
	}

	public Serializable getCompareState() {
		return compareState;
	}

	public void setCompareState(Serializable compareState) {
		this.compareState = compareState;
	}

	public Serializable getValue1() {
		return value1;
	}

	public void setValue1(Serializable value1) {
		this.value1 = value1;
	}

	public Serializable getValue2() {
		return value2;
	}

	public void setValue2(Serializable value2) {
		this.value2 = value2;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}
}
